import { CoolController, BaseController, CoolUrlTag, TagTypes } from '@cool-midway/core';
import { Body, Get, Inject, Post, Query } from '@midwayjs/core';
import { UserAdEntity } from '../../entity/ad';
import { UserAdService } from '../../service/adInfo';

/**
 * 用户-广告播放信息
 */
@CoolUrlTag({
  key: TagTypes.IGNORE_TOKEN,
  value: ['info', 'list', 'page'],
})
@CoolController({
  api: ['add', 'delete', 'update', 'info', 'list', 'page'],
  entity: UserAdEntity,
  service: UserAdService,
  insertParam: (ctx => {
    return {
      // 获得当前登录的后台用户ID，需要请求头传Authorization参数
      userId: ctx.user.id
    }
  }),
})
export class AppUserAddressesController extends BaseController {
  @Inject()
  userAdService: UserAdService;
  @Get('/advertisingPermission', { summary: '判断需不需要观看广告' })
  async advertisingPermission() {
    return this.ok(await this.userAdService.advertisingPermission());
  }
}
